//app.js
App({
  globalData: {
    navBar: {
      // 导航高度
      navHeight: 0,
      // 状态栏高度
      statusBarHeight: 0,
      // 标题栏高度
      titleBarHeight: 0,
      // 胶囊距状态栏的高度
      menuBtnTop: 0
    }
  },
  onLaunch: function () {
    // 获取胶囊的数据
    const menuBtnObject  = wx.getMenuButtonBoundingClientRect()
    // 获取状态栏的高度，并存储
    const statusBarHeight = wx.getSystemInfoSync().statusBarHeight
    // 获取标题栏的高度
    const titleBarHeight = menuBtnObject.height + (menuBtnObject.top - statusBarHeight) * 2

    this.globalData.navBar.menuBtnTop = menuBtnObject.top - statusBarHeight
    this.globalData.navBar.statusBarHeight = statusBarHeight
    this.globalData.navBar.titleBarHeight = titleBarHeight   
    this.globalData.navBar.navHeight = statusBarHeight + titleBarHeight

    if(!wx.cloud) {
      console.log('请使用 2.2.3 或以上的基础库以使用云能力')
    }else {
      wx.cloud.init({
        env: "minijingdong-6gmzb5oc4447b462",
        traceUser: true
      })
    }
  },

  // globalData: {
   
  // },
  // onLaunch: function () {
  //   let menuButtonObject = wx.getMenuButtonBoundingClientRect();
  //   wx.getSystemInfo({
  //     success: res => {
  //       let statusBarHeight = res.statusBarHeight,
  //         navTop = menuButtonObject.top,//胶囊按钮与顶部的距离
  //         navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight)*2;//导航高度
  //       this.globalData.navHeight = navHeight;
  //       this.globalData.navTop = navTop;
  //       this.globalData.windowHeight = res.windowHeight;
  //     },
  //     fail(err) {
  //       console.log(err);
  //     }
  //   })
  // },
  onShow: function(options){

  },
  onHide: function(){

  },
  onError: function(msg){

  },
  //options(path,query,isEntryPage)
  onPageNotFound: function(options){

  }
})